package lc.oa.ui.base;

import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.widget.Toast;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;


/**
 * 基类
 */
public class MyAppCompatActivity extends AppCompatActivity {
    public MyAppCompatActivity(){
        System.out.println("MyAppCompatActivity 构造器------>");
    }
    private long extTime=0;
    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {

        if (keyCode==KeyEvent.KEYCODE_BACK){
            if (System.currentTimeMillis()-extTime>2000){
                Toast.makeText(getApplicationContext(),"再按一次退出哦!",Toast.LENGTH_LONG).show();
                extTime=System.currentTimeMillis();
            }
            else {
                System.exit(0);
            }
            return false;
        }
        return super.onKeyDown(keyCode, event);
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //DaggerAnalyticsComponent.builder().build().inject(this);
        //((App) getApplication()).inject(this);

    }
}
